﻿<!--<link href="Common/RoadFlow/Themes/Common.css" rel="stylesheet" />
<link href="Common/RoadFlow/Themes/Blue/Style/style.css" id="style_style" rel="stylesheet" type="text/css" media="screen" />
<link href="Common/RoadFlow/Themes/Blue/Style/ui.css" id="style_ui" rel="stylesheet" type="text/css" media="screen" />-->
<!--<script src="Common/RoadFlow/Scripts/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript" src="Common/RoadFlow/Scripts/json.js"></script>-->
<!--<script type="text/javascript" src="common/roadflow/scripts/roadui.core.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.tab.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.window.js"></script>


<script type="text/javascript" src="common/roadflow/scripts/roadui.button.js"></script>
<script type="text/javascript" src="common/roadflow/scripts/roadui.calendar.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.file.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.member.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.dict.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.menu.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.select.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.combox.js"></script>

<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.text.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.textarea.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.editor.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.tree.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.validate.js"></script>

<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.dragsort.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.selectico.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.accordion.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.grid.js"></script>
<script type="text/javascript" src="Common/RoadFlow/Scripts/roadui.init.js"></script>-->

<div class="toolbar" style="margin-top:0; border-top:none 0;">
    <a href="javascript:;" onclick="openFlow(); return false;" class="layui-btn layui-btn-sm ng-scope">打开</a>
    <a href="javascript:;" onclick="addFlow(); return false;" class="layui-btn layui-btn-sm ng-scope">
        新建
    </a>
    <a href="javascript:;" onclick="flowAttrSetting(); return false;" class="layui-btn layui-btn-sm ng-scope">
        属性
    </a>

    <span class="toolbarsplit">&nbsp;</span>

    <a href="javascript:;" onclick="addStep(); return false;" class="layui-btn layui-btn-sm ng-scope">
        步骤
    </a>

    <a href="javascript:;" onclick="addSubFlow(); return false;" class="layui-btn layui-btn-sm ng-scope">
        子流程
    </a>

    <a href="javascript:;" onclick="addConn(); return false;" class="layui-btn layui-btn-sm ng-scope">
        连线
    </a>
    <a href="javascript:;" onclick="copyStep(); return false;" class="layui-btn layui-btn-sm ng-scope">
        复制
    </a>
    <a href="javascript:;" onclick="removeObj(); return false;" title="删除当前选定对象" class="layui-btn layui-btn-sm ng-scope">
        删除
    </a>
    <span class="toolbarsplit">&nbsp;</span>

    <a href="javascript:;" onclick="saveFlow('save'); return false;" class="layui-btn layui-btn-sm ng-scope">
        保存
    </a>
    <a href="javascript:;" onclick="saveAs(); return false;" class="layui-btn layui-btn-sm ng-scope">
        另存为
    </a>

    <span class="toolbarsplit">&nbsp;</span>

    <a href="javascript:;" onclick="saveFlow('install'); return false;" class="layui-btn layui-btn-sm ng-scope">
        安装
    </a>
    <a href="javascript:;" onclick="saveFlow('uninstall'); return false;" class="layui-btn layui-btn-sm ng-scope">
        卸载
    </a>
    <a href="javascript:;" onclick="saveFlow('delete'); return false;" title="删除流程" class="layui-btn layui-btn-sm ng-scope">
        删除
    </a>
</div>

<div id="flowdiv" style="margin:0; padding:0;"></div>
<script src="Common/oa/js/draw-min.js"></script>
<script src="Common/oa/js/workflow.js" type="text/javascript"></script>

<form class="layui-form" action="" hidden id="flowadd" style="display:none" lay-filter="example">

    <div class="tabdiv" id="flowtabdiv">
        <div id="div_base" title="基本信息">
            <div style="height:8px;"></div>
            <table cellpadding="0" cellspacing="1" border="0" width="99%" class="formtable">
                <tr>
                    <th style="width:100px;">流程ID：</th>
                    <td><input type="text" id="base_ID" name="base_ID" readonly="readonly" value="05e38316-3e67-4a1c-975f-b9808e46d159" class="mytext" style="width:75%" /></td>
                </tr>
                <tr>
                    <th>流程名称：</th>
                    <td><input type="text" id="base_Name" name="base_Name" class="mytext" style="width:75%" /></td>
                </tr>
                <tr>
                    <th>流程分类：</th>
                    <td>
                        <select id="base_Type" name="base_Type" class="myselect" style="margin-right:5px;"><option value=""></option><option value="48d05cf9-81c2-4713-87ab-1a45321500de">办公类流程</option>0<option value="90d6ad24-28f5-49d3-ac3f-cb473fb64cc5">业务类流程</option>0</select>
                        <!--
                        类型：<select class="myselect" id="base_FlowType" name="base_FlowType">

                           </select>
                        -->
                    </td>
                </tr>
                <tr>
                    <th>管理者：</th>
                    <td><input type="text" id="base_Manager" value="u_eb03262c-ab60-4bc6-a4c0-96e66a4229fe" name="base_Manager" class="mymember" title="选择流程管理者" more="1" user="1" dept="1" station="1" workgroup="1" style="width:75%" /></td>
                </tr>
                <tr>
                    <th>实例管理者：</th>
                    <td><input type="text" id="base_InstanceManager" value="u_eb03262c-ab60-4bc6-a4c0-96e66a4229fe" name="base_InstanceManager" class="mymember" title="选择流程实例管理者" more="1" user="1" dept="1" station="1" workgroup="1" style="width:75%" /></td>
                </tr>
                <tr>
                    <th>删除已完成：</th>
                    <td>
                        <select id="base_RemoveCompleted" name="base_RemoveCompleted" class="myselect" style="width:120px;">
                            <option value="0">不删除</option>
                            <option value="1">删除</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>调试模式：</th>
                    <td>
                        <select class="myselect" id="base_Debug">
                            <option value="0">关闭</option>
                            <option value="1">开启(有调试窗口)</option>
                            <option value="2">开启(无调试窗口)</option>
                        </select>
                        <input type="text" id="base_DebugUsers" title="选择调试人员" class="mymember" /> //调试人员
                    </td>
                </tr>
                <tr>
                    <th>备注：</th>
                    <td><textarea rows="1" cols="1" id="base_Note" name="base_Note" class="mytext" style="width:90%; height:40px;"></textarea></td>
                </tr>
            </table>
        </div>
        <div id="div_data" title="数据连接">
            <div style="height:8px;"></div>
            <table cellpadding="0" cellspacing="1" border="0" width="99%" style="width:99%" class="listtable" id="link_listtable">
                <thead>
                    <tr>
                        <th style="width:28%">数据库连接</th>
                        <th style="width:28%">数据表</th>
                        <th style="width:30%">主键</th>
                        <th><a href="javascript:link_add();"><img alt="" src="../../Images/ico/add.gif" style="border:0; vertical-align:middle;" /><span style="vertical-align:middle;">添加</span></a></th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <div id="div_title" title="标识字段">
            <div style="height:8px;"></div>
            <table cellpadding="0" cellspacing="1" border="0" width="99%" class="formtable">
                <tr>
                    <th style="width:100px;">数据连接：</th>
                    <td>
                        <select id="title_dbconn" name="title_dbconn" class="myselect"
                                onchange="title_db_change(this)" style="width:400px;">
                            <option value=""></option>
                            <option value="06075250-30dc-4d32-bf97-e922cb30fac8">平台连接</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>数据表：</th>
                    <td><select id="title_tables" onchange="title_table_change(this)" name="title_tables" class="myselect" style="width:400px;"></select></td>
                </tr>
                <tr>
                    <th>完成标识：</th>
                    <td><select id="title_title" name="title_title" class="myselect" style="width:400px;"></select></td>
                </tr>
            </table>
        </div>
    </div>
    <div style="width:99%; margin:8px auto 0 auto; text-align:center;">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="flowaddsubmit">确定</button>
                <button class="layui-btn">取消</button>
            </div>
        </div>

        <!--<input type="button" class="mybutton" value=" 确 定 " onclick="confirm1(this)" />
        <input type="button" class="mybutton" value=" 取 消 " onclick="new RoadUI.Window().close();" />-->
    </div>
</form>
<script type="text/javascript">
    var link_options = '<option value=""></option><option value="06075250-30dc-4d32-bf97-e922cb30fac8" >平台连接</option>'; //数据连接选项
    var isAdd = '1' == '1';
    var openerid = 'tab_aa80e3aa6547416e839ba25bc7f2a099';
    var flowID = '05e38316-3e67-4a1c-975f-b9808e46d159';
    var defaultManager = 'u_eb03262c-ab60-4bc6-a4c0-96e66a4229fe';
    var win = new RoadUI.Window();
    var frame = null;

    $(function () {
        new RoadUI.Tab({ id: "flowtabdiv", replace: true, contextmenu: false });
        var iframes = top.frames;
        for (var i = 0; i < iframes.length; i++) {
            if (iframes[i].name == openerid + "_iframe") {
                frame = iframes[i]; break;
            }
        }
        if (frame == null) return;

        if (!isAdd) {
            var json = frame.wf_json;
            if (json) {
                $("#base_Name").val(json.name);
                $("#base_Type").val(json.type);
                $("#base_Manager").val(json.manager || defaultManager); new RoadUI.Member().setValue($("#base_Manager"));
                $("#base_InstanceManager").val(json.instanceManager || defaultManager); new RoadUI.Member().setValue($("#base_InstanceManager"));
                $("#base_RemoveCompleted").val(json.removeCompleted);
                $("#base_Note").val(json.note);
                $("#base_Debug").val(json.debug);
                $("#base_DebugUsers").val(json.debugUsers); new RoadUI.Member().setValue($("#base_DebugUsers"));
                $("#base_FlowType").val(json.flowType || "");
                var databases = json.databases;
                if (databases) {
                    for (var i = 0; i < databases.length; i++) {
                        link_add(databases[i].link, databases[i].table, databases[i].primaryKey);
                    }
                }
                if (json.titleField) {
                    $("#title_dbconn").val(json.titleField.link);
                    $("#title_tables").html(getTables(json.titleField.link, json.titleField.table));
                    $("#title_title").html(getFields(json.titleField.link, json.titleField.table, json.titleField.field));
                }
            }
        }
    });


    function link_add(db, table, field) {
        var tableOptions = '';
        var fieldOptions = '';
        if (db && table) {
            tableOptions = getTables(db, table);
        }
        if (db && table && field) {
            fieldOptions = getFields(db, table, field);
        }
        var index = $("#link_listtable tbody tr").size() + 1;
        var tr = '<tr>';
        tr += '<td style="background:#ffffff; height:30px;">';
        tr += '<input type="hidden" name="link_index" value="' + index.toString() + '"/>';
        tr += '<select class="myselect" style="width:120px" onchange="link_db_change(this);" id="link_db_' + index.toString() + '" name="link_db_' + index.toString() + '">' + link_options + '</select></td>';
        tr += '<td style="background:#ffffff;"><select class="myselect" style="width:120px" onchange="link_table_change(this)" id="link_table_' + index.toString() + '" name="link_table_' + index.toString() + '">' + tableOptions + '</select></td>';
        tr += '<td style="background:#ffffff;"><select class="myselect" style="width:120px" id="link_key_' + index.toString() + '" name="link_key_' + index.toString() + '">' + fieldOptions + '</select></td>';
        tr += '<td style="background:#ffffff;"><a href="javascript:link_delete(' + index.toString() + ');" class="deletelink">删除</a></td>';
        tr += '</tr>';
        $("#link_listtable tbody").append(tr);
        new RoadUI.Select().init($(".myselect", $("#link_listtable tbody")));
        if (db) {
            $("#link_db_" + index.toString()).val(db);
        }
    }
    function link_delete(index) {
        $("#link_listtable tbody tr td input[type='hidden']").each(function () {
            if ($(this).val() == index.toString()) {
                $(this).parent().parent().remove();
            }
        });
    }
    function link_db_change(obj, table) {
        if (!obj || !obj.value) return;
        var html = getTables(obj.value, table);
        $("select", $(obj).parent().next()).html(html);
    }
    function getTables(connid, table) {
        var options = '<option value=""></option>';
        var tableds = frame.getTables(connid);
        for (var i = 0; i < tableds.length; i++) {
            options += '<option value="' + tableds[i].name + '" ' + (tableds[i].name == table ? 'selected="selected"' : '') + '>' + tableds[i].name + '</option>';
        }
        return options;
    }
    function link_table_change(obj, field) {
        if (!obj || !obj.value) return;
        var conn = $("select", $(obj).parent().prev()).val();
        $("select", $(obj).parent().next()).html(getFields(conn, obj.value, field));
    }
    function getFields(connid, table, field) {
        var options = '<option value=""></option>';
        var fields = frame.getFields(connid, table);
        for (var i = 0; i < fields.length; i++) {
            options += '<option value="' + fields[i].name + '" ' + (fields[i].name == field ? 'selected="selected"' : '') + '>' + fields[i].name + (fields[i].note ? '(' + fields[i].note + ')' : '') + '</option>';
        }
        return options;
    }

    function title_db_change(obj, table) {
        if (!obj || !obj.value) return;
        $("#title_tables").html(getTables(obj.value, table));

    }
    function title_table_change(obj, fields) {
        if (!obj || !obj.value) return;
        var conn = $("#title_dbconn").val();
        $("#title_title").html(getFields(conn, obj.value, fields));
    }



    function confirm1(but) {
        $(but).prop("disabled", true);
        if (isAdd) {
            frame.initwf();
        }
        var json = frame.wf_json;
        json.id = flowID;
        json.name = $("#base_Name").val() || '';
        json.type = $("#base_Type").val() || '';
        json.manager = $("#base_Manager").val() || '';
        json.instanceManager = $("#base_InstanceManager").val() || '';
        json.removeCompleted = $("#base_RemoveCompleted").val() || '';
        json.debug = $("#base_Debug").val() || "0";
        json.debugUsers = $("#base_DebugUsers").val() || '';
        json.note = $("#base_Note").val() || '';
        json.flowType = $("#base_FlowType").val() || "";
        json.databases = [];
        $("input[type='hidden'][name='link_index']").each(function () {
            var index = $(this).val();
            json.databases.push({
                link: $('#link_db_' + index).val() || '',
                linkName: $("#link_db_" + index + " option[value='" + ($('#link_db_' + index).val() || '') + "']").text(),
                table: $('#link_table_' + index).val() || '',
                primaryKey: $('#link_key_' + index).val() || ''
            });
        });
        json.titleField = {
            link: $("#title_dbconn").val() || '',
            table: $("#title_tables").val() || '',
            field: $("#title_title").val() || ''
        };

        frame.wf_id = flowID;
        frame.initLinks_Tables_Fields(json.databases);
        new RoadUI.Window().close();
    }
</script>



<form action="" class="layui-form" hidden id="flowsx" style="display:none" lay-filter="flowsx">
    <div class="tabdiv" id="flowsxtabdiv">
        <div id="div_base" title="&nbsp;&nbsp;基本&nbsp;&nbsp;">
            <div style="height:8px;"></div>
            <table cellpadding="0" cellspacing="1" border="0" width="99%" class="formtable">
                <tr>
                    <th>步骤ID：</th>
                    <td colspan="3"><input type="text" id="base_ID" value="ab617576-2842-4d39-8db6-f74435d1edef" class="mytext" readonly="readonly" style="width:75%" /></td>
                </tr>
                <tr>
                    <th>步骤名称：</th>
                    <td colspan="3"><input type="text" id="base_Name" class="mytext" style="width:75%" /></td>
                </tr>
                <tr>
                    <th style="width:100px">意见显示：</th>
                    <td style="width:35%">
                        <select class="myselect" value1="1" style="width:75%;" id="base_OpinionDisplay">
                            <option value="1">显示</option>
                            <option value="0">不显示</option>
                        </select>
                    </td>
                    <th style="width:100px">超期提示：</th>
                    <td style="width:35%">
                        <select class="myselect" value1="1" style="width:75%;" id="base_ExpiredPrompt">
                            <option value="1">提示</option>
                            <option value="0">不提示</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>审签类型：</th>
                    <td>
                        <select class="myselect" value1="2" style="width:75%;" id="base_SignatureType">
                            <option value="0">无签批意见栏</option>
                            <option value="1">有签批意见(无须签章)</option>
                            <option value="2">有签批意见(须签章)</option>
                        </select>
                    </td>
                    <th>工时(小时)：</th>
                    <td><input type="text" id="base_WorkTime" class="mytext" style="width:73%;" /></td>
                </tr>
                <tr>
                    <th>是否归档：</th>
                    <td>
                        <select class="myselect" value1="0" style="width:75%;" id="base_Archives">
                            <option value="0">不归档</option>
                            <option value="1">归档</option>
                        </select>
                    </td>
                    <th></th>
                    <td></td>
                </tr>
                <tr>
                    <th>表单：</th>
                    <td colspan="3">
                        <select class="myselect" style="width:130px; max-height:200px;" onchange="form_types_change(this.value);" id="form_types">
                            <option value=""></option>
                            <option value="7bc7c158-3492-41dd-8082-388495edf20c">流程分类</option>0
                            <option value="48d05cf9-81c2-4713-87ab-1a45321500de">┝办公类流程</option>1
                            <option value="90d6ad24-28f5-49d3-ac3f-cb473fb64cc5">┝业务类流程</option>1
                            <option value="719c6c30-3d6a-44e2-8730-637c651f1df7">表单分类</option>0
                            <option value="7283b92f-21b4-4b0a-8b00-72cc9656f4dc">┝自定义表单</option>1
                            <option value="2a1070f6-af14-45b3-8292-fe0962701c04">┝普通表单</option>1
                            <option value="74facc24-969f-4604-bc21-ce9e14dfa1ed">&nbsp;&nbsp;┝合同类表单</option>2
                            <option value="626480b3-eaa9-4705-acbb-82901db4fda4">&nbsp;&nbsp;┝办公类表单</option>2
                            <option value="94decd1d-8c60-4c85-8f00-e740c1d4847b">系统管理</option>0
                            <option value="ba6a867d-75ec-4223-b123-84229e29ff0c">流程管理</option>0
                        </select>
                        <select class="myselect" style="width:390px;" id="form_forms"></select>
                    </td>
                </tr>
                <tr>
                    <th>说明：</th>
                    <td colspan="3"><textarea id="base_Note" class="mytext" style="width:89%; height:50px;"></textarea></td>
                </tr>
            </table>
        </div>

        <div id="div_behavior" title="&nbsp;&nbsp;策略&nbsp;&nbsp;">
            <div style="height:8px;"></div>
            <table cellpadding="0" cellspacing="1" border="0" width="99%" class="formtable">
                <tr>
                    <th style="width:13%">流转类型：</th>
                    <td style="width:37%">
                        <select class="myselect" style="width:210px;" id="behavior_FlowType">
                            <option value="1">单选一个分支流转</option>
                            <option value="0">系统控制</option>
                            <option value="2">多选几个分支流转</option>
                        </select>
                    </td>
                    <th>运行时选择：</th>
                    <td>
                        <select class="myselect" style="width:210px;" id="behavior_RunSelect">
                            <option value="1">允许</option>
                            <option value="0">不允许</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>处理者类型：</th>
                    <td>
                        <select class="myselect" style="width:210px;" id="behavior_HandlerType">
                            <option value="0">所有成员</option>
                            <option value="1">部门</option>
                            <option value="2">岗位</option>
                            <option value="3">工作组</option>
                            <option value="4">人员</option>
                            <option value="5">发起者</option>
                            <option value="6">前一步骤处理者</option>
                            <option value="7">某一步骤处理者</option>
                            <option value="8">字段值</option>
                            <option value="9">发起者领导</option>
                            <option value="10">发起者分管领导</option>
                            <option value="11">前一步处理者领导</option>
                            <option value="12">前一步处理者分管领导</option>
                        </select>
                    </td>
                    <th>选择范围：</th>
                    <td><input type="text" id="behavior_SelectRange" onchange="handlerTypeCng()" user="1" more="1" dept="1" station="1" workgroup="1" class="mymember" style="width:169px;" /></td>
                </tr>
                <tr>
                    <th>处理者步骤：</th>
                    <td>
                        <select class="myselect" style="width:210px;" id="behavior_HandlerStep"></select>
                    </td>
                    <th>值字段：</th>
                    <td>
                        <select class="myselect" style="width:210px;" id="behavior_ValueField"></select>
                    </td>
                </tr>
                <tr>
                    <th>默认处理者：</th>
                    <td><input type="text" class="mymember" dept="1" station="1" workgroup="1" user="1" more="1" id="behavior_DefaultHandler" style="width:169px;" /></td>
                    <th>退回策略：</th>
                    <td>
                        <select class="myselect" style="width:210px;" id="behavior_BackModel">
                            <option value="1">根据处理策略退回</option>
                            <option value="0">不能退回</option>
                        </select>
                    </td>
                </tr>

                <tr>
                    <th>处理策略：</th>
                    <td>
                        <select class="myselect" style="width:210px;" id="behavior_HanlderModel">
                            <option value="0">所有人必须同意</option>
                            <option value="1">一人同意即可</option>
                            <option value="2">依据人数比例</option>
                            <option value="3">独立处理</option>
                        </select>
                    </td>
                    <th>退回类型：</th>
                    <td>
                        <select class="myselect" style="width:210px;" id="behavior_BackType">
                            <option value="0">退回前一步</option>
                            <option value="1">退回第一步</option>
                            <option value="2">退回某一步</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>策略百分比：</th>
                    <td><input type="text" id="behavior_Percentage" class="mytext" style="width:191px" /> %</td>
                    <th>退回步骤：</th>
                    <td>
                        <select class="myselect" style="width:210px;" id="behavior_BackStep"></select>
                    </td>
                </tr>
                <tr>
                    <th>会签策略：</th>
                    <td>
                        <select class="myselect" value1="0" style="width:210px;" id="behavior_Countersignature">
                            <option value="0">不会签</option>
                            <option value="1">所有步骤同意</option>
                            <option value="2">一个步骤同意即可</option>
                            <option value="3">依据比例</option>
                        </select>
                    </td>
                    <th>会签百分比：</th>
                    <td>
                        <input type="text" id="behavior_CountersignaturePercentage" class="mytext" style="width:191px" /> %
                    </td>
                </tr>
                <tr>
                    <th>抄送：</th>
                    <td>
                        <input type="text" class="mymember" dept="1" station="1" workgroup="1" user="1" more="1" id="behavior_CopyFor" style="width:169px;" />
                    </td>
                    <th></th>
                    <td></td>
                </tr>
            </table>
        </div>

        <!--
        <div id="div_form" class="mytab_div" style="display:none; width:99%; margin:0 auto;">
        <div>
            <table cellpadding="0" cellspacing="1" border="0">
                <tr>
                    <td style="padding-right:4px;">
                        <select class="myselect" style="width:130px; max-height:200px;" onchange="form_types_change(this.value);" id="form_types">
                            <option value=""></option>

                        </select>
                    </td>
                    <td>

                    </td>

                    <td style="padding-left:3px;"><input type="button" class="mybutton" value="添加" onclick="form_add();" /></td>

                </tr>
            </table>
        </div>
        <div style="border:0px solid #e8e8e8; margin-top:6px; padding:3px 5px 3px 5px;" id="form_list">
            <div style="width:98%;"></div>
        </div>
        </div>
        -->

        <div id="div_button" style="width:99%;margin:0 auto;" title="&nbsp;&nbsp;按钮&nbsp;&nbsp;">
            <div style="height:8px;"></div>
            <div id="button_List" style="width:220px; height:270px; overflow:auto; border:1px solid #e8e8e8; padding:3px; float:left;">
                <div style="width:94%;">
                    <ul class="listulli" note="按钮之间的分隔线" title="按钮之间的分隔线" val="other_splitline" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)">---分隔线---</ul>

                    <ul class="listulli" note="打印当前表单" title="打印当前表单" val="29b358e1-ad64-4f09-846c-4554ae6b85c4" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/printer.gif) no-repeat left;padding-left:20px;">打印</label></ul>

                    <ul class="listulli" note="" title="" val="7217b1b1-663d-4f7a-83ff-5b89047ace51" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/topic.gif) no-repeat left;padding-left:20px;">查看主流程表单</label></ul>

                    <ul class="listulli" note="刷新当前流程页面" title="刷新当前流程页面" val="da7c699c-3c55-4657-8781-6881ac9117b7" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/Refresh.png) no-repeat left;padding-left:20px;">刷新</label></ul>

                    <ul class="listulli" note="将当前任务转交给其他人处理" title="将当前任务转交给其他人处理" val="347b811c-7568-4472-9a61-6c31f66980ae" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/arrow_medium_lower_right.png) no-repeat left;padding-left:20px;">转交</label></ul>

                    <ul class="listulli" note="退回到上一步或某一步" title="退回到上一步或某一步" val="86b7fa6c-891f-4565-9309-81672d3ba80a" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/arrow_medium_left.png) no-repeat left;padding-left:20px;">退回</label></ul>

                    <ul class="listulli" note="完成流程" title="完成流程" val="954effa8-03b8-461a-aaa8-8727d090dcb9" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/role.gif) no-repeat left;padding-left:20px;">完成</label></ul>

                    <ul class="listulli" note="查看子流程表单及处理过程" title="查看子流程表单及处理过程" val="fd768e2b-5739-4bc1-b397-8a151bc0881d" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/rgb.png) no-repeat left;padding-left:20px;">查看子流程</label></ul>

                    <ul class="listulli" note="保存当前任务，下次继续处理" title="保存当前任务，下次继续处理" val="3b271f67-0433-4082-ad1a-8df1b967b879" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/save.gif) no-repeat left;padding-left:20px;">保存</label></ul>

                    <ul class="listulli" note="发送到下一步" title="发送到下一步" val="8982b97c-adba-4a3a-afd9-9a3ef6ff12d8" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/arrow_medium_right.png) no-repeat left;padding-left:20px;">发送</label></ul>

                    <ul class="listulli" note="显示当前流程设计图" title="显示当前流程设计图" val="c40fb454-4e1a-414f-9a3a-ac66a998c8a7" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/shape_aling_left.png) no-repeat left;padding-left:20px;">流程图</label></ul>

                    <ul class="listulli" note="关闭窗口" title="关闭窗口" val="da606ff2-cdf2-4363-8212-cc7c633fb2f2" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/application_osx_remove.png) no-repeat left;padding-left:20px;">关闭</label></ul>

                    <ul class="listulli" note="保存自定义表单" title="保存自定义表单" val="b47b6455-ebbc-493d-9e8a-cfd8ea7d95f4" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/saveas.gif) no-repeat left;padding-left:20px;">保存</label></ul>

                    <ul class="listulli" note="查看流程处理过程" title="查看流程处理过程" val="b8a7af17-7ad5-4699-b679-d421691dd737" onmouseover="$(this).removeClass().addClass('listulli1');" onmouseout="if($currentButton==null || $currentButton.get(0)!==this){$(this).removeClass().addClass('listulli');}" onclick="button_click(this);" ondblclick="button_dblclick(this)"><label style="background:url(../..//Images/ico/search.png) no-repeat left;padding-left:20px;">过程查看</label></ul>

                </div>
            </div>
            <div style="float:left; width:50px; text-align:center; padding-top:100px;">
                <input type="button" class="mybutton" value="添加" onclick="button_add();" /><br /><br />
                <input type="button" class="mybutton" value="删除" onclick="button_remove();" />
            </div>
            <div id="button_Select" style="width:220px; height:270px; overflow:auto; border:1px solid #e8e8e8; padding:3px; float:left;">
                <div style="width:94%;"></div>
            </div>
            <div style="width:20px; height:270px; float:left;"></div>
            <div id="button_Note" style="width:150px; height:270px; overflow:auto; border:1px solid #e8e8e8; padding:3px; float:left; overflow:auto;">
                <div style="font-weight:bold; line-height:22px;">按钮说明：</div>
                <div id="button_Note1" style="line-height:22px;"></div>
            </div>
            <div style="clear:both;"></div>
        </div>

        <div id="div_data" style="width:99%; margin:0 auto;" title="&nbsp;&nbsp;数据&nbsp;&nbsp;">
            <div style="height:8px;"></div>
            <table cellpadding="0" cellspacing="1" border="0">
                <tr>
                    <td>数据表：</td>
                    <td style="padding-right:8px;"><select class="myselect" id="data_alltable" style="width:140px;"></select></td>
                    <td style="height:32px;">将所有字段设置为：</td>
                    <td style="padding-right:8px;"><select class="myselect" id="data_allstate" onchange="data_StateCng(this.value)"><option value=""></option><option value="0">编辑</option><option value="1">只读</option><option value="2">隐藏</option></select></td>
                    <td>将所有字段检查设置为：</td>
                    <td><select class="myselect" id="data_allcheck" style="width:120px;" onchange="data_CheckCng(this.value)"><option value=""></option><option value="0">不检查</option><option value="1">允许为空,非空时检查</option><option value="2">不允许为空,并检查</option></select></td>
                </tr>
            </table>
            <div style="width:100%; height:256px; overflow:auto;">
                <table cellpadding="0" cellspacing="1" border="0" width="100%" class="listtable" id="data_table">
                    <thead>
                        <tr>
                            <th>数据连接</th>
                            <th>数据表</th>
                            <th>字段名称</th>
                            <th>字段状态</th>
                            <th>数据检查</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>

        <div id="div_event" title="&nbsp;&nbsp;事件&nbsp;&nbsp;">
            <div style="height:8px;"></div>
            <table cellpadding="0" cellspacing="1" border="0" width="99%" class="formtable">
                <tr>
                    <th style="width:130px;">步骤提交前事件：</th>
                    <td><input type="text" id="event_SubmitBefore" class="mytext" style="width:75%" /></td>
                </tr>
                <tr>
                    <th>步骤提交后事件：</th>
                    <td><input type="text" id="event_SubmitAfter" class="mytext" style="width:75%" /></td>
                </tr>
                <tr>
                    <th>步骤退回前事件：</th>
                    <td><input type="text" id="event_BackBefore" class="mytext" style="width:75%" /></td>
                </tr>
                <tr>
                    <th>步骤退回后事件：</th>
                    <td><input type="text" id="event_BackAfter" class="mytext" style="width:75%" /></td>
                </tr>
            </table>

        </div>
    </div>
    <div style="width:100%; margin:10px auto 10px auto; text-align:center;">
        <input type="button" class="mybutton" value=" 确 定 " onclick="confirm1();" />
        <input type="button" class="mybutton" value=" 取 消 " onclick="new RoadUI.Window().close();" />
    </div>
</form>
<script type="text/javascript">

    $(function () {
        new RoadUI.Tab({ id: "flowsxtabdiv", replace: true, contextmenu: false });
        //var iframes = top.frames;
        //for (var i = 0; i < iframes.length; i++) {
        //    if (iframes[i].name == openerid + "_iframe") {
        //        frame = iframes[i]; break;
        //    }
        //}
        //if (frame == null) return;


        //初始化行为里面字段值选择项以及字段状态列表
        var fields = frame.links_tables_fields;
        var tables = [];
        if (fields && fields.length > 0) {
            var trs = '';
            var valueFieldOptions = '<option value=""></option>';
            for (var i = 0; i < fields.length; i++) {
                valueFieldOptions += '<option value="' + fields[i].link + '.' + fields[i].table + '.' + fields[i].field + '">' + fields[i].linkName + '.' + fields[i].table + '.' + fields[i].field + (fields[i].fieldNote ? '(' + fields[i].fieldNote + ')' : '') + '</option>';
                trs += '<tr>';
                trs += '<td style="background:#ffffff; height:30px;">';
                trs += '<input type="hidden" value="' + i.toString() + '" id="data_check_index_' + i.toString() + '" />';
                trs += '<input type="hidden" value="' + fields[i].link + '.' + fields[i].table + '.' + fields[i].field + '" id="data_check_field_' + i.toString() + '" />';
                trs += fields[i].linkName + '</td>';
                trs += '<td style="background:#ffffff;">' + fields[i].table + '</td>';
                trs += '<td style="background:#ffffff;">' + fields[i].field + (fields[i].fieldNote ? '(' + fields[i].fieldNote + ')' : '') + '</td>';
                trs += '<td style="background:#ffffff;"><select class="myselect" id="data_check_status_' + i.toString() + '" style="width:60px;"><option value="0">编辑</option><option value="1">只读</option><option value="2">隐藏</option></select></td>';
                trs += '<td style="background:#ffffff;"><select class="myselect" id="data_check_check_' + i.toString() + '" style="width:100px;"><option value="0">不检查</option><option value="1">允许为空,非空时检查</option><option value="2">不允许为空,并检查</option></select></td>';
                trs += '</tr>';
                tables.push(fields[i].table);
            }
            $("#behavior_ValueField").html(valueFieldOptions);
            $("#data_table tbody").append(trs);
            new RoadUI.Select().init($(".myselect", $("#data_table tbody")));
        }
        //初始化所有表过滤下拉选择
        tables = tables.unique();
        var tablesoptions = '<option value=""></option>';
        for (var i = 0; i < tables.length; i++) {
            tablesoptions += '<option value="' + tables[i] + '">' + tables[i] + '</option>';
        }
        $("#data_alltable").html(tablesoptions).bind("change", function () {
            var value = $(this).val();
            var $trs = $("#data_table tbody tr");
            if (value.length == 0) {
                $trs.show();
                return;
            }

            for (var i = 0; i < $trs.size(); i++) {
                var $tds = $("td", $trs.eq(i));
                if ($tds.size() > 2 && $tds.eq(1).text() != value) {
                    $trs.eq(i).hide();
                }
                else {
                    $trs.eq(i).show();
                }
            }
        });


        var json = frame.wf_json;
        var step;

        if (json && json.steps && json.steps.length > 0) {
            var stepOptions = '<option value=""></option>';//初始化行为里面的处理者步骤和退回步骤选择
            for (var i = 0; i < json.steps.length; i++) {
                if (json.steps[i].id == stepid) {
                    step = json.steps[i];
                }
                else {
                    stepOptions += '<option value="' + json.steps[i].id + '">' + json.steps[i].name + '</option>';
                }
            }
            $("#behavior_HandlerStep").html(stepOptions);
            $("#behavior_BackStep").html(stepOptions);
        }

        initStep(step);

        //按钮排序
        new RoadUI.DragSort($("#button_Select div"));

    });

    function form_types_change(value) {
        $.ajax({
            url: top.rootdir + "/Platform/RoleApp/GetApps.ashx", data: { type: value }, async: false, type: "post", success: function (txt) {
                $("#form_forms").html('<option value=""></option>' + txt);
            }
        });
    }

    function form_add(formid, formtitle, formtype) {
        formid = formid || $("#form_forms").val();
        if (!formid) {
            alert("请选择要添加的表单!");
            return false;
        }
        else if ($("#form_list div ul[val='" + formid + "']").size() > 0) {
            alert("该表单已经添加了!");
            return false;
        }
        var formtitle = formtitle || $("#form_forms option[value='" + formid + "']").text();
        var formtype = formtype || $("#form_types option[value='" + $("#form_types").val() + "']").text();

        var $ul = $('<ul class="listulli" val="' + formid + '"><span>' + formtitle +
            '</span> - <span style="color:#999999;">' + formtype + '</span>' +
            '<span onclick="form_remove(this); return false;" style="padding-right:12px; margin-left:10px; height:18px; line-height:18px; cursor:pointer;' +
            ' background:url(../../Images/ico/cancel.gif) no-repeat left; padding-left:19px;"><a href="javascript:form_remove(this);return false;">删除</a></span></ul>');

        $("#form_list div").append($ul);

        new RoadUI.DragSort($("#form_list div"));
    }
    function form_remove(span) {
        //if (confirm("您真的要删除该表单吗?"))
        //{
        $(span).parent().remove();
        //new RoadUI.DragSort($("#form_list div"));
        //}
    }

    var $currentButton = null;
    function button_click(ul) {
        $currentButton = $(ul);
        var $buttons = null;
        if ($currentButton.parent().parent().attr('id') == "button_List") {
            $buttons = $("#button_List div ul");
        }
        else if ($currentButton.parent().parent().attr('id') == "button_Select") {
            $buttons = $("#button_Select div ul");
        }
        $buttons.each(function () {
            $(this).removeClass().addClass("listulli");
        });
        $(ul).removeClass().addClass("listulli1");
        $("#button_Note1").text($(ul).attr("note"));
    }

    function button_dblclick(ul) {
        button_click(ul);
        button_add();
    }

    function button_add() {
        if ($currentButton == null) {
            alert("请选择要添加的按钮!"); return false;
        }
        if ($currentButton.parent().parent().attr('id') == "button_List") {
            if ($("#button_Select div ul[val='" + $currentButton.attr("val") + "']").size() > 0) {
                alert("当前按钮已经选择了!"); return false;
            }
            $("#button_Select div").append($currentButton.clone());
        }
        else if ($currentButton.parent().parent().attr('id') == "button_Select") {
            $currentButton.remove();
        }
        $currentButton = null;
        new RoadUI.DragSort($("#button_Select div"));
    }
    function button_remove() {
        if ($currentButton == null) {
            alert("请选择要删除的按钮!"); return false;
        }
        $currentButton.remove();
        new RoadUI.DragSort($("#button_Select div"));
    }

    function initStep(step) {
        if (!step) {
            $("#base_Name").val("新步骤");
            return;
        }

        $("#base_Name").val(step.name);
        if (step.opinionDisplay) $("#base_OpinionDisplay").val(step.opinionDisplay);
        if (step.expiredPrompt) $("#base_ExpiredPrompt").val(step.expiredPrompt);
        if (step.signatureType) $("#base_SignatureType").val(step.signatureType);
        if (step.workTime) $("#base_WorkTime").val(step.workTime);
        //if(step.limitTime) $("#base_LimitTime").val(step.limitTime);
        //if(step.otherTime) $("#base_OtherTime").val(step.otherTime);
        if (step.archives) $("#base_Archives").val(step.archives);
        if (step.note) $("#base_Note").val(step.note);

        if (step.behavior.flowType) $("#behavior_FlowType").val(step.behavior.flowType);
        if (step.behavior.runSelect) $("#behavior_RunSelect").val(step.behavior.runSelect);
        if (step.behavior.handlerType) $("#behavior_HandlerType").val(step.behavior.handlerType);
        if (step.behavior.selectRange) {
            $("#behavior_SelectRange").val(step.behavior.selectRange);
            new RoadUI.Member().setValue($("#behavior_SelectRange"));
        }
        if (step.behavior.handlerStep) $("#behavior_HandlerStep").val(step.behavior.handlerStep);
        if (step.behavior.valueField) $("#behavior_ValueField").val(step.behavior.valueField);
        if (step.behavior.defaultHandler) {
            $("#behavior_DefaultHandler").val(step.behavior.defaultHandler);
            new RoadUI.Member().setValue($("#behavior_DefaultHandler"));
        }
        if (step.behavior.hanlderModel) $("#behavior_HanlderModel").val(step.behavior.hanlderModel);
        if (step.behavior.backModel) $("#behavior_BackModel").val(step.behavior.backModel);
        if (step.behavior.backType) $("#behavior_BackType").val(step.behavior.backType);
        if (step.behavior.backStep) $("#behavior_BackStep").val(step.behavior.backStep);
        if (step.behavior.percentage) $("#behavior_Percentage").val(step.behavior.percentage);
        if (step.behavior.countersignature) $("#behavior_Countersignature").val(step.behavior.countersignature);
        if (step.behavior.countersignaturePercentage) $("#behavior_CountersignaturePercentage").val(step.behavior.countersignaturePercentage);
        if (step.behavior.copyFor) {
            $("#behavior_CopyFor").val(step.behavior.copyFor);
            new RoadUI.Member().setValue($("#behavior_CopyFor"));
        }

        var forms = step.forms;
        if (forms && forms.length > 0) {
            for (var i = 0; i < forms.length; i++) {
                //form_add(forms[i].id,forms[i].name,forms[i].type);
                $('#form_types').val(forms[i].type);
                form_types_change(forms[i].type);
                $("#form_forms").val(forms[i].id);
            }
        }

        var buttons = step.buttons;
        if (buttons && buttons.length > 0) {
            for (var i = 0; i < buttons.length; i++) {
                var $ul = $("#button_List div ul[val='" + buttons[i].id + "']");
                if ($ul.size() > 0) {
                    $currentButton = $ul;
                    button_add();
                }
            }
        }

        initDataFiledStatus(step.fieldStatus);

        if (step.event) {
            $("#event_SubmitBefore").val(step.event.submitBefore);
            $("#event_SubmitAfter").val(step.event.submitAfter);
            $("#event_BackBefore").val(step.event.backBefore);
            $("#event_BackAfter").val(step.event.backAfter);
        }
    }

    function initDataFiledStatus(fields)//初始化字段状态列表
    {
        if (!fields || fields.length == 0) {
            return;
        }

        $("#data_table tbody tr").each(function () {
            var field = $("input[id^='data_check_field_']", $(this)).val();
            var status = "0";
            var check = "0";
            for (var i = 0; i < fields.length; i++) {
                if (fields[i].field == field) {
                    status = fields[i].status;
                    check = fields[i].check;
                    break;
                }
            }
            $("select[id^='data_check_status_']", $(this)).val(status)
            $("select[id^='data_check_check_']", $(this)).val(check)
        });
    }

    function data_StateCng(value) {
        $("select:visible[id^='data_check_status_']", $("#data_table tbody")).val(value);
    }

    function data_CheckCng(value) {
        $("select:visible[id^='data_check_check_']", $("#data_table tbody")).val(value);
    }

    function confirm1() {
        var step = {};
        step.id = stepid;
        step.type = "normal";
        step.name = $("#base_Name").val() || "";
        step.opinionDisplay = $("#base_OpinionDisplay").val() || "";
        step.expiredPrompt = $("#base_ExpiredPrompt").val() || "";
        step.signatureType = $("#base_SignatureType").val() || "";
        step.workTime = $("#base_WorkTime").val() || "";
        step.limitTime = "" // $("#base_LimitTime").val() || "";
        step.otherTime = "" // $("#base_OtherTime").val() || "";
        step.archives = $("#base_Archives").val() || "";
        step.archivesParams = $("#base_ArchivesParams").val() || "";
        step.note = $("#base_Note").val() || "";
        step.position = { x: 10, y: 50, width: 108, height: 50 };
        step.countersignature = $("#base_Countersignature_1").prop("checked") ? 1 : 0;

        step.behavior = {
            flowType: $("#behavior_FlowType").val() || "",
            runSelect: $("#behavior_RunSelect").val() || "",
            handlerType: $("#behavior_HandlerType").val() || "",
            selectRange: $("#behavior_SelectRange").val() || "",
            handlerStep: $("#behavior_HandlerStep").val() || "",
            valueField: $("#behavior_ValueField").val() || "",
            defaultHandler: $("#behavior_DefaultHandler").val() || "",
            hanlderModel: $("#behavior_HanlderModel").val() || "",
            backModel: $("#behavior_BackModel").val() || "",
            backType: $("#behavior_BackType").val() || "",
            backStep: $("#behavior_BackStep").val() || "",
            percentage: $("#behavior_Percentage").val() || "",
            countersignature: $("#behavior_Countersignature").val() || "0",
            countersignaturePercentage: $("#behavior_CountersignaturePercentage").val() || "",
            copyFor: $("#behavior_CopyFor").val() || ""
        };

        step.forms = [];
        //$("#form_list div ul").each(function(i){
        //    var $spans=$(this).children('span');
        //    step.forms.push({ id: $(this).attr("val"), name:$spans.eq(0).text(), type:$spans.eq(1).text(), srot:i });
        //});
        var form_type = $('#form_types').val() || "";
        var form_forms = $("#form_forms").val() || "";
        if (form_forms.length > 0 && form_type.length > 0) {
            step.forms.push({ id: form_forms, name: "", type: form_type, srot: 0 });
        }

        step.buttons = [];
        $("#button_Select div ul").each(function (i) {
            step.buttons.push({ id: $(this).attr("val"), sort: i });
        });

        step.fieldStatus = [];
        $("#data_table tbody input[type='hidden'][id^='data_check_index_']").each(function (i) {
            var index = $(this).val();
            var fields = $("#data_check_field_" + index).val();
            var status = $("#data_check_status_" + index).val();
            var check = $("#data_check_check_" + index).val();
            step.fieldStatus.push({ field: fields, status: status, check: check });
        });

        step.event = {
            submitBefore: $("#event_SubmitBefore").val() || "",
            submitAfter: $("#event_SubmitAfter").val() || "",
            backBefore: $("#event_BackBefore").val() || "",
            backAfter: $("#event_BackAfter").val() || ""
        };

        //frame.addStep1(step);
        //frame.setStepText(step.id, step.name);
        //new RoadUI.Window().close();
    }
</script>

